package com.boco.ibssystem.business.controller.ylfwjg;

import com.boco.biinjectionserviceapi.service.config.ISqlTemplateInfoService;
import com.boco.biinjectionserviceapi.vo.Params;
import com.boco.ibssystem.business.service.IYlxwService;
import com.boco.ibssystem.business.vo.CountData;
import com.boco.ibssystem.business.vo.PieData;
import com.boco.ibssystem.common.result.AjaxResult;
import com.boco.ibssystem.common.result.support.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author : yichaofan
 * @date : 2019年05月09日 8:47
 * @email : hjljy@outlook.com
 * @version : v1.0
 * @description : 医疗行为监管controller
 */
@RestController
@RequestMapping("/ylxw/")
@Api(tags = "医疗行为监管")
@ResponseResult
public class YlxwController {

    @Autowired
    private IYlxwService service;
    @Autowired
    private ISqlTemplateInfoService sqlTemplateInfoService;

    @GetMapping("/ywxw/pie")
    @ApiOperation(value = "药物行为：饼图数据获取")
    public Map<String, List<PieData>> getPieData(@ApiParam(name = "参数对象", value = "传入json格式", required = false) Params params) {
        Map<String, List<PieData>> map = new HashMap<>();

        List<PieData> count = new ArrayList<>();
        PieData data = service.getmzyfy(params);
        data.setName("门诊人均药费用数据");
        PieData data1 = service.getzyyfy(params);
        data1.setName("住院人均药费用数据");
        count.add(data);
        count.add(data1);
        map.put("药费用数据", count);
        return map;
    }

    @GetMapping("/ywxw/mzkj")
    @ApiOperation(value = "药物行为：查询门诊抗菌药物信息 待做")
    public AjaxResult getMZKJ() throws Exception {
        List<HashMap<String, Object>> query = sqlTemplateInfoService.query(3L);
        //TODO 功能待做，无法判断处方明细当中的抗菌药物信息
        return new AjaxResult("功能待做，无法判断处方明细当中的抗菌药物信息");
    }


    @GetMapping("/ywxw/zykj")
    @ApiOperation(value = "药物行为：查询住院抗菌药物信息")
    public AjaxResult getZYKJ() throws Exception {
        List<HashMap<String, Object>> query = sqlTemplateInfoService.query(3L);
        //TODO 功能待做，无法判断抗菌药物信息
        return new AjaxResult("功能待做，无法判断抗菌药物信息");
    }

    @GetMapping("/zdxw/pie")
    @ApiOperation(value = "诊断行为：诊断饼图数据")
    public Map<String, List<PieData>> getZdxwPie(@ApiParam(name = "参数对象", value = "传入json格式", required = false) Params params){
        Map<String, List<PieData>> map = new HashMap<>();

        List<PieData> data = new ArrayList<>();
        PieData count = service.getAllCount(params);
        PieData getmzzy = service.getmzzy(params);
        PieData getzycy = service.getzycy(params);
        data.add(count);
        data.add(getmzzy);
        data.add(getzycy);
        List<PieData> pieData = service.getzxzd(params);
        map.put("诊断符合率数据",data);
        map.put("中西医诊断数据",pieData);
        return map;
    }

    @GetMapping("/zdxw/bar")
    @ApiOperation(value = "诊断行为：诊断疾病信息数据")
    public Map<String,List<CountData>> getZdxwBar(@ApiParam(name = "参数对象", value = "传入json格式", required = false) Params params){

        return  service.getZdxwCountData(params);
    }

    @GetMapping("/zlxw/pie")
    @ApiOperation(value = "治疗行为：治疗类别统计")
    public List<PieData> getZllbPie(@ApiParam(name = "参数对象", value = "传入json格式", required = false) Params params){

        return  service.getZllbPie(params);
    }

    @GetMapping("/zlxw/line")
    @ApiOperation(value ="治疗行为：患者治疗数据" )
    public Map<String,List<CountData>> getHzzlData(@ApiParam(name = "参数对象", value = "传入json格式", required = false) Params params){

        return service.getHzzlData(params);
    }

    @GetMapping("/ssxw/pie")
    @ApiOperation(value = "手术行为：饼图数据")
    public Map<String,List<PieData>> getSsxwPie(@ApiParam(name = "参数对象", value = "传入json格式", required = false) Params params){

        return service.getSsxwPie(params);
    }

    @GetMapping("/ssxw/line")
    @ApiOperation(value ="手术行为：手术台数统计数据" )
    public List<CountData> getSstjData(@ApiParam(name = "参数对象", value = "传入json格式", required = false) Params params){

        return service.getSstjData(params);
    }
}
